include_javaScript(url_prefix + 'editor/ckeditor/ckeditor.js');
include_javaScript(url_prefix + 'editor/ckfinder/ckfinder.js');

var dem = 0;
var email = new Array();
var time_delay = 3000;
$(function () {
    $("#tabs").tabs();
});

$(document).ready(function () {
    hs.graphicsDir = url_base + 'app/admin/view/temp/default/layout/css/highslide/graphics/';
    hs.align = 'center';
    hs.closeText = '<img border="0" src="' + url_base + 'app/admin/view/temp/default/layout/css/highslide/graphics/close_X.png" />';
    hs.creditsText = 'this.a.title';
    hs.outlineType = 'rounded-white';
    hs.showCredits = false;
    hs.wrapperClassName = 'draggable-header';
    hs.cacheAjax = false;
    hs.dimmingOpacity = 0.7;
    hs.onDimmerClick = function () {
        return false;
    }

    //getmail();
});

function getmail() {
    var strData = _seokey[0] + "/" + _seokey[1] + "/ajax/getemail/";
    $.ajax({
        type:"POST",
        url:url_base + "" + strData,
        cache:false,
        success:function (DataHtml) {
            email = JSON.parse(DataHtml);
            count();

//            sentmail(DataHtml);
        }
    });
}

function count() {
    var count = email.length;
    if (dem < count) {
        sentmail(email[dem][0],email[dem][1]);
        dem = dem + 1;
    }
}

function sentmail(email,ID) {
    setTimeout(function () {
        var strData = _seokey[0] + "/" + _seokey[1] + "/ajax/sentmail/"+email+ "/" + ID;
        $.ajax({
            type:"POST",
            url:url_base + "" + strData,
            cache:false,
            dataType:"html",
            success:function (DataHtml) {

                count();
               // alert(email);
            }
        });
    }, time_delay);
}
function sentmail_one(email,ID) {
        $("#sent"+ID).attr("style","background:center url('"+url_base+"upload/ajax-loader.gif') no-repeat;min-width:94px");
        var btn =$("#sent"+ID).html();
        $("#sent"+ID).html("");
        var strData = _seokey[0] + "/" + _seokey[1] + "/ajax/sentmail/"+email+ "/" + ID;
        $.ajax({
            type:"POST",
            url:url_base + "" + strData,
            cache:false,
            dataType:"html",
            success:function (DataHtml) {
                             $("#sent"+ID).attr("style","background:center url('"+url_base+"upload/ajax-loader.gif') no-repeat;min-width:94px");
                            $("#sent"+ID).html(btn);
                           var amount = parseInt($("#btn_sent"+ID).attr("amount"));
                            $("#btn_sent"+ID).attr("amount",amount+1);
                            $("#btn_sent"+ID).val(  _['sent_mail'] +"(" +(amount+1)+")");

            }
        });

}










